<admintpl file="header" />
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Member/agent')}">代理管理</a></li>
        <li class="active"><a href="{:U('Member/agentadd')}">代理详情</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:U('Member/agentedit_post')}" method="post">
        <fieldset>
            <div class="control-group">
                <label class="control-label">代理账号</label>
                <div class="controls">
                    <input type="text" name="A_NAME" value="{$agent.a_name}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">密码</label>
                <div class="controls">
                    <input type="password" name="A_PASSWORD" value="{$agent.a_password}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">真实姓名</label>
                <div class="controls">
                    <input type="text" name="A_REALNAME" value="{$agent.a_realname}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">性别</label>
                <div class="controls">
                <php>$state_true_checked=($agent['a_sex']=="男")?"checked":"";</php>
                <php>$state_false_checked=($agent['a_sex']=="女")?"checked":"";</php>
                    <input type="radio" name="A_SEX" value="男" {$state_true_checked}>男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="A_SEX" value="女" {$state_false_checked}>女
                </div>
            </div>
            <div class="control-group"><!-- A_CONTENT -->
                <label class="control-label">地址</label>
                <div class="controls">
                    <select name="sheng" id="provinces" style="width: 80px">
                        <option value="-1">省份</option>
                        <foreach name="citys" item="val">
                            <option value="{$val.region_id}">{$val.region_name}</option>
                        </foreach>
                    </select>&nbsp;&nbsp;
                    <select name="shi" id="citys" style="width: 90px">
                        <option value="-1">地级市</option>
                    </select>&nbsp;&nbsp;
                    <select name="qu" id="qu" style="width: 110px" onchange="showArea()">
                        <option value="-1">区、县、镇</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"></label>
                <div class="controls">
                    <input type="text" name="A_CONTENT" readonly id="A_Content" value="{$agent.a_content}" class="textbox form-control">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">手机号</label>
                <div class="controls">
                    <input type="text" name="A_MOBILE" value="{$agent.a_mobile}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">微信号</label>
                <div class="controls">
                    <input type="text" name="A_WEIXIN" value="{$agent.a_weixin}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">是否可以解散房间</label>
                <div class="controls">
                <php>$disband_true_checked=($agent['is_disband']==1)?"checked":"";</php>
                <php>$disband_false_checked=($agent['is_disband']==0)?"checked":"";</php>
                    <input type="radio" name="is_disband" value="1" {$disband_true_checked}>是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="is_disband" value="0" {$disband_false_checked}>否
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">状态</label>
                <div class="controls">
                <php>$state_true_checked=($agent['a_state']==1)?"checked":"";</php>
                <php>$state_false_checked=($agent['a_state']==0)?"checked":"";</php>
                    <input type="radio" name="A_STATE" value="1" {$state_true_checked}>启用&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="A_STATE" value="0" {$state_false_checked}>禁用
                </div>
            </div>
        </fieldset>
        <div class="form-actions">
				<input type="hidden" name="id" value="{$agent.agentid}"/>
				<button type="submit" class="btn btn-primary  js-ajax-submit">{:L('SAVE')}</button>
            <a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    $(document).ready(function() {
        Wind.css('treeTable');
        Wind.use('treeTable', function() {
            $("#menus-table").treeTable({
                indent : 20
            });
        });
        //  加载所有的省份
        $.ajax({
            type: "get",
            url: "__URL__/sheng", // type=1表示查询省份
            data: {"parent_id": "1", "type": "1"},
            dataType: "json",
            success: function(data) {
                $("#provinces").html("<option value=''>省份</option>");
                $.each(data, function(i, item) {
                    $("#provinces").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                });
            }
        });
        //  加载所有的市
        $("#provinces").change(function() {
            $.ajax({
                type: "get",
                url: "__URL__/sheng", // type =2表示查询市
                data: {"parent_id": $(this).val(), "type": "2"},
                dataType: "json",
                success: function(data) {
                    $("#citys").html("<option value=''>地级市</option>");
                    $.each(data, function(i, item) {
                        $("#citys").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                    });
                }
            });
        });
        //  加载所有的区
        $("#citys").change(function() {
            $.ajax({
                type: "get",
                url: "__URL__/sheng", // type =3表示查询区
                data: {"parent_id": $(this).val(), "type": "3"},
                dataType: "json",
                success: function(data) {
                    $("#qu").html("<option value=''>区、县、镇</option>");
                    $.each(data, function(i, item) {
                        $("#qu").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                    });
                }
            });
        });
    });

    setInterval(function() {
        var refersh_time = getCookie('refersh_time_admin_menu_index');
        if (refersh_time == 1) {
            reloadPage(window);
        }
    }, 1000);
    setCookie('refersh_time_admin_menu_index', 0);
    
    function showArea() {
    	var provinces = document.getElementById('provinces');
    	var citys = document.getElementById('citys');
    	var qu = document.getElementById('qu');
        document.getElementById('A_Content').value = provinces.options[provinces.selectedIndex].text + " - " + citys.options[citys.selectedIndex].text + " - " + qu.options[qu.selectedIndex].text + "";
    }
</script>
</body>
</html>